Avoid unnecessary window flushes
authorAlexander Larsson <alexl@redhat.com>
Wed, 22 Aug 2012 15:01:15 +0000 (17:01 +0200)
committerAlexander Larsson <alexl@redhat.com>
Thu, 23 Aug 2012 10:16:43 +0000 (12:16 +0200)
The code was calling _gdk_window_ref_cairo_surface in a few places
where the intent was not to read/write to the surface, but just look
at its type (to e.g. create a similar surface). This is bad, as that
operation causes a flush which may cause unnecessary work and/or
flashing. Instead we just get the impl surface in these cases.

gdk/gdkwindow.c

index 978eaa6c58a0f9bacd6b49bbf0baf8b5a0f223c7..2a807ce83f011d5905bd5cd867c69b13e7ba23f6 100644 (file)
@@ -254,6 +254,7 @@ static void gdk_window_invalidate_rect_full (GdkWindow          *window,
                                             gboolean            invalidate_children,
                                             ClearBg             clear_bg);
 static void _gdk_window_propagate_has_alpha_background (GdkWindow *window);
+static cairo_surface_t *gdk_window_ref_impl_surface (GdkWindow *window);
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
@@ -2671,7 +2672,7 @@ gdk_window_get_content (GdkWindow *window)
 
   g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
 
-  surface = _gdk_window_ref_cairo_surface (window);
+  surface = gdk_window_ref_impl_surface (window);
   content = cairo_surface_get_content (surface);
   cairo_surface_destroy (surface);
 
@@ -10129,7 +10130,7 @@ gdk_window_create_similar_surface (GdkWindow *     window,
 
   g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
   
-  window_surface = _gdk_window_ref_cairo_surface (window);
+  window_surface = gdk_window_ref_impl_surface (window);
 
   switch (_gdk_rendering_mode)
   {